package com.doit.day05

import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author:
 * @WX: 17710299606
 * @Tips: 学大数据 ,到多易教育
 * @DOC: https://blog.csdn.net/qq_37933018?spm=1000.2115.3001.5343
 * @Description:
 */
object Demo02 {

  def main(args: Array[String]): Unit = {

       val  conf  = new SparkConf()
             .setMaster("local[*]")
             .setAppName(this.getClass.getSimpleName)
           val sc = SparkContext.getOrCreate(conf)

    val   a1 = sc.makeRDD(List("a a a a a a a a b b "))

    val a2 = a1.flatMap(_.split("\\s+"))

    val a3 = a2.map((_, 1))

    val a4 = a3.groupBy(_._1)

    a4.map(e=>e).map(e=>e).foreach(println)

    a4.map(e=>(e,e)).map(e=>(e,e)).foreach(println)




  }

}
